/*
 * Custom Tabbed Pane UI
 */
package gui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.plaf.basic.BasicTabbedPaneUI;

/**
 * The UI for the tabbed pane we're using
 * @author Kay van Bree
 */
public class CustomTabbedPaneUI extends BasicTabbedPaneUI {
	
	public CustomTabbedPaneUI(){}
	
	/*
	* Take space of borders
	* @author Kay van Bree
	*/
	@Override
	protected Insets getContentBorderInsets(int tabPlacement){
		return new Insets(0, 0, 0, 0);
	}

	/**
	* Remove the original border of the tabbed pane
	* @author Kay van Bree
	*/
	@Override
	protected void paintContentBorder(Graphics g, int tabPlacement,int selectedIndex){
		// We don't take kindly on your kind of borders around here!
	}
	
	/**
	 * Taken from BasicTabbedPaneUI and edited it, 'cause them bitches gave selectedColor private access!
	 * @author Kay van Bree
	 */
	@Override
	protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected ) {
		Color selectedColor = Color.WHITE;
        g.setColor(!isSelected?	tabPane.getBackgroundAt(tabIndex) : selectedColor);
        switch(tabPlacement) {
          case LEFT:
              g.fillRect(x+1, y+1, w-1, h-3);
              break;
          case RIGHT:
              g.fillRect(x, y+1, w-2, h-3);
              break;
          case BOTTOM:
              g.fillRect(x+1, y, w-3, h-1);
              break;
          case TOP:
          default:
              g.fillRect(x+1, y+1, w-3, h-1);
        }
		
		paintTabBorder(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
    }
	
	
}
